import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {

    @Insert("INSERT INTO user(username, age) VALUES(#{username}, #{age})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertUser(User user);

    @Delete("DELETE FROM user WHERE id = #{id}")
    void deleteUser(int id);

    @Update("UPDATE user SET username = #{username}, age = #{age} WHERE id = #{id}")
    void updateUser(User user);

    @Select("SELECT * FROM user WHERE id = #{id}")
    User selectUser(int id);

    @Select("SELECT * FROM user")
    List<User> selectAllUsers();
}
